//go:build !windows
// +build !windows

package framework

import (
	"Hypnos-Soundcore/components/config"
	"github.com/fvbock/endless"
	"net/http"
)

// ListenAndServe listen and serve
func ListenAndServe(xconf *config.XConfig, engine http.Handler) error {
	var serveErr error
	if xconf.Network.UseHTTPS {
		serveErr = endless.ListenAndServeTLS(xconf.Network.ListenPort, xconf.Network.CertFile,
			xconf.Network.KeyFile, engine)
	} else {
		serveErr = endless.ListenAndServe(xconf.Network.ListenPort, engine)
	}
	return serveErr
}
